package com.huaxia.day3a;

/**
 * 操作符实例
 */
public class TypeTransform {
    private static int age = 25;

    public static void main(String[] args) {
//        Person.speak();
//        t4();
//        t2();
//          t4();
//        t5();
//        test6();
        test7();
    }


    /**
     * 移位
     */
    public static void t2() {
        int i = 6 >> 1;
        System.out.println("t2:" + i);
        System.out.println(1 << 2);
        System.out.println(8 >> 2);
    }

    /**
     * 拼接
     */
    public static void t3() {
        String ss = 6 + 6 + "X";
        if (ss instanceof String) {
            System.out.println("这个变量是String类型");
        }
        System.out.println(6 + 6 + "x");
        System.out.println("" + 6 + 6 + "x");
        System.out.println("x" + 6 + 6);

        ss += " test";
        ss = ss + " test";
        System.out.println(ss);


    }

    /**
     * 加减
     */

    public static void t4() {
        int i = 0;
        int j = 108;

        System.out.println(i++);
        System.out.println(++i);
        System.out.println(--j);

        System.out.println(1 / 3);
        System.out.println((double) 1 / 3);
    }

    /**
     * 逻辑操作符
     * 与或非 逻辑门的区别
     */

    public static void t5() {
        boolean t1 = true;
        boolean t2 = false;
        boolean t3 = false;
        System.out.println(t1 || t2);
        System.out.println(!t2 && t1);
        System.out.println(t2 && t3);
        System.out.println(t2 & t3);
    }

    /**
     * 赋值操作符
     */

    public static void test6() {
        int num0 = 10;
        String name = "tom";
        num0 += 12;// num0 = num0 + 12;
        System.out.println(num0);

        num0 -= 1;
        System.out.println(num0);

        int k = 63;
        //取余
        System.out.println(k % 10);
        //除
        System.out.println(k / 2);

    }


    /**
     * 三元运算符
     */


    public static void test7() {
        int a = 12;
        int b = 34;
        int num = a > b ? 1 : -1;
        System.out.println("三元结果:" + num);

        if (a > b) {
            System.out.println(1);
        } else {
            System.out.println(-1);

        }

    }

}
